<html>
    <head>
        <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
        <link rel="preload" href="/node_modules/@perspective-dev/server/dist/wasm/perspective-server.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
        <link rel="preload" href="/node_modules/@perspective-dev/viewer/dist/wasm/perspective-viewer.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
        <link rel="stylesheet" crossorigin="anonymous" href="/node_modules/@perspective-dev/viewer/dist/css/pro.css" />
        <link rel="stylesheet" crossorigin="anonymous" href="/node_modules/@perspective-dev/workspace/dist/css/pro.css" />
        <style>
            perspective-workspace {
                position: absolute;
                top: 0;
                bottom: 0;
                left: 0;
                right: 0;
            }

            body {
                overflow: hidden;
            }
        </style>
    </head>
    <body>
        <perspective-workspace id="workspace"></perspective-workspace>
        <script type="module">
            import "/node_modules/@perspective-dev/viewer/dist/cdn/perspective-viewer.js";
            import "/node_modules/@perspective-dev/workspace/dist/cdn/perspective-workspace.js";
            import "/node_modules/@perspective-dev/viewer-datagrid/dist/cdn/perspective-viewer-datagrid.js";
            import "/node_modules/@perspective-dev/viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js";

            import perspective from "/node_modules/@perspective-dev/client/dist/cdn/perspective.js";

            const DATA_URL = "/node_modules/superstore-arrow/superstore.lz4.arrow";

            async function get_layout() {
                const req = await fetch("layout.json");
                const json = await req.json();
                return json;
            }

            const datasource = async () => {
                const request = fetch(DATA_URL);
                const worker = await perspective.worker();
                const response = await request;
                const buffer = await response.arrayBuffer();
                return await worker.table(buffer);
            };

            window.workspace.tables.set("superstore", datasource());
            const layout = await get_layout();
            window.workspace.restore(layout);
        </script>
    </body>
</html>
